Loading...
 

Algorithm of LU factorization with pivoting

How to convert Gaussian elimination with pivoting to LU factorization with pivoting? An additional matrix must be entered \( {\bf P} \) that is responsible for pivoting.


We start from
\( {\bf P}=\begin{bmatrix} 1 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 1 \\ \end{bmatrix} \)
\( {\bf L}= \begin{bmatrix} 1 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 1 \\ \end{bmatrix} \)
\( {\bf U}= \begin{bmatrix} 0.05 & 0.10833 & 0.00833 & 0 & 0 \\ 0.10833 & 0.5 & 0.21666 & 0.00833 & 0 \\ 0.00833 & 0.21666 & 0.55 & 0.21666 & 0.00833 \\ 0 & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \)
In the first step, we do a pivot in the first column \( {\bf U } \), so we swap the first and the second rows. We mark it by swapping the first and second lines in the matrix \( {\bf P } \).
\( {\bf L}= \begin{bmatrix} 1 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 1 \\ \end{bmatrix} \)
Additionally we swap rows in \( {\bf U} \)
\( {\bf U}= \begin{bmatrix} 0.10833 & 0.5 & 0.21666 & 0.00833 & 0 \\ 0.05 & 0.10833 & 0.00833 & 0 & 0 \\ 0.00833 & 0.21666 & 0.55 & 0.21666 & 0.00833 \\ 0 & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \)
Then we scale the new first row, storing the value from the diagonal of the matrix \( {\bf U} \) in matrix \( {\bf L} \).
\( 1^{st}=1^{st}*A(1,1)=1^{st}\frac{1}{0.10833}=1^{st}*9.231053 \)
\( {\bf U}= \begin{bmatrix} {\color{blue}0.10833}*9.23105 & 0.5*9.23105 & 0.21666*9.23105 & 0.00833*9.23105 & 0 \\ 0.05 & 0.10833 & 0.00833 & 0 & 0 \\ 0.00833 & 0.21666 & 0.55 & 0.21666 & 0.00833 \\ 0 & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \)
\( {\bf L}= \begin{bmatrix} {\color{blue}0.10833} & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 1 \\ \end{bmatrix} \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2.00006 & 0.07693 & 0 \\ {\color{blue}0.05} & 0.10833 & 0.00833 & 0 & 0 \\ 0.00833 & 0.21666 & 0.55 & 0.21666 & 0.00833 \\ 0 & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \)
We subtract rows by writing the value at the beginning of the row to be eliminated in the corresponding row in the matrix \( {\bf L } \) (denoted in blue)
\( 2^{nd}=2^{nd}-1^{st}*A(2,1)=2^{nd}-1^{st}*{\color{blue}0.05} \)
\( {\bf L}= \begin{bmatrix} 0.10833 & 0 & 0 & 0 & 0 \\ {\color{blue}0.05} & 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 1 \\ \end{bmatrix} \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 0.10833-4.61553*0.05 & 0.00833-2*0.05 & 0-0.07693*0.05 & 0 \\ 0.00833 & 0.21666 & 0.55 & 0.21666 & 0.00833 \\ 0 & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & -0.12244 & -0.09167 & -0,00385 & 0 \\ {\color{blue}0.00833} & 0.21666 & 0.55 & 0.21666 & 0.00833 \\ 0 & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \)
\( 3^{rd}=3^{rd}-1^{st}*A(3,1)=3^{rd}-1^{st}*{\color{blue}0.00833} \)
\( {\bf L}= \begin{bmatrix} 0.10833 & 0 & 0 & 0 & 0 \\ 0.05 & 1 & 0 & 0 & 0 \\ {\color{blue}0.00833} & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 1 \\ \end{bmatrix} \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & -0.12244 & -0.09167 & -0,00385 & 0 \\ 0 & 0.21666-4.61552*0.00833 & 0.55-2*0.00833 & 0.21666-0.07689*0.00833 & 0.00833-0 \\ 0 & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & {\color{red}-0.12244} & -0.09167 & -0,00385 & 0 \\ 0 & {\color{red}0.17821} & 0.53334 & 0.21603 & 0.00833 \\ 0 & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \)
We now pivot the second column again, replacing the second row with the third because \( |{\color{red}0.17821}|>|{\color{red}-0.12244}|=0.12244 \). We replace the columns in the matrix \( {\bf U } \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & {\color{red}0.17821} & 0.53334 & 0.21603 & 0.00833 \\ 0 & {\color{red}-0.12244} & -0.09167 & -0,00385 & 0 \\ 0 & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \)
We mark it by swapping the second and third rows in the matrix \( {\bf P } \)
\( {\bf P}= \begin{bmatrix} 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 \\ 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 1 \\ \end{bmatrix} \)
Now we scale the new second row, saving the value from the diagonal in the matrix \( {\bf L } \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & {\color{blue}0.17821} & 0.53334 & 0.21603 & 0.00833 \\ 0 & -0.12244 & -0.09167 & -0,00385 & 0 \\ 0 & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \)
\( 2^{nd}=2^{nd}/A(2,2)=2^{nd}/0.17821=2^{nd}*5.61135 \)
\( {\bf L}=\begin{bmatrix} 0.10833 & 0 & 0 & 0 & 0 \\ 0.05 & {\color{blue}0.17821} & 0 & 0 & 0 \\ 0.00833 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 1 \\ \end{bmatrix} \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 0.17821*5.61135 & 0.53334*5.61135 & 0.21603*5.61135 & 0.00833*5.61135 \\ 0 & -0.12244 & -0.09167 & -0,00385 & 0 \\ 0 & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99275 & 1.21222 & 0.046742 \\ 0 & {\color{blue}-0.12244} & -0.09167 & -0,00385 & 0 \\ 0 & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \)
We subtract the rows and write the values at the beginning of the rows in the matrix \( {\bf L} \)
\( 3^{rd}=3^{rd}-2^{nd}*A(3,2)=3^{rd}-2^{nd}*({\color{blue}-0.12244}) \)
\( {\bf L}= \begin{bmatrix} 0.10833 & 0 & 0 & 0 & 0 \\ 0.05 & 0.17821 & 0 & 0 & 0 \\ 0.00833 & {\color{blue}-0.12244} & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 1 \\ \end{bmatrix} \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & -0.09167+2.99275*0.12244 & -0,00385+1.21222*0.12244 & 0+0.046742*0.12244 \\ 0 & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 0.27479 & 0.14459 & 0.00573 \\ 0 & {\color{blue}0.00833} & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \)
\( 4^{th}=4^{th}-2^{nd}*A(4,2)=4^{th}-2^{nd}*{\color{blue}0.00833} \)
\( {\bf L}= \begin{bmatrix} 0.10833 & 0 & 0 & 0 & 0 \\ 0.05 & 0.17821 & 0 & 0 & 0 \\ 0.00833 & -0.12244 & 1 & 0 & 0 \\ 0 & {\color{blue}0.00833} & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 1 \\ \end{bmatrix} \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 0.27476 & 0.14457 & 0.005723 \\ 0 & 0 & 0.21666-2.99275*0.00833 & 0.5-1.21210*0.00833 & 0.10833-0.046742*0.00833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 0.27476 & 0.14457 & 0.005723 \\ 0 & & 0.19173 & 0.48990 & 0.10794 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \)
In the third column, you don't have to do pivoting because the value from the diagonal \( A(3,3)={\color{red}0.27476} \) (denoted in red) is the largest, so we do not need to swap the rows in \( {\bf U } \) neither in \( {\bf P } \)
So we scale the third row by writing the appropriate value in the matrix \( {\bf L } \).
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & {\color{blue}0.27476} & 0.14457 & 0.005723 \\ 0 & & 0.19173 & 0.48990 & 0.10794 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \)
\( 3^{rd}=3^{rd}/A(3,3)=3^{rd}/0.27476=3^{rd}*3.63953 \)
\( {\bf L}= \begin{bmatrix} 0.10833 & 0 & 0 & 0 & 0 \\ 0.05 & 0.17821 & 0 & 0 & 0 \\ 0.00833 & -0.12244 & {\color{blue}0.27476} & 0 & 0 \\ 0 & 0.00833 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 1 \\ \end{bmatrix} \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 0.27476*3.63953 & 0.14457*3.63953 & 0.005723*3.63953 \\ 0 & 0 & 0.19173 & 0.48990 & 0.10794 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \)
We eliminate the rows by writing the appropriate values into the matrix \( {\bf L} \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 1 & 0.52617 & 0.02082 \\ 0 & 0 & {\color{blue}0.19173} & 0.48990 & 0.10794 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \)
\( 4^{th}=4^{th}-3^{rd}*A(4,3)=4^{th}-3^{rd}*0.19173 \)
\( {\bf L}= \begin{bmatrix} 0.10833 & 0 & 0 & 0 & 0 \\ 0.05 & 0.17821 & 0 & 0 & 0 \\ 0.00833 & -0.12244 & 0.27476 & 0 & 0 \\ 0 & 0.00833 & {\color{blue}0.19173} & 1 & 0 \\ 0 & 0 & 0 & 0 & 1 \\ \end{bmatrix} \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 1 & 0.52617 & 0.02082 \\ 0 & 0 & 0& 0.48990-0.52618*0.19173 & 0.10794-0.02083*0.19173 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 1 & 0.52617 & 0.02082 \\ 0 & 0 & 0 & 0.38901 & 0.10395 \\ 0 & 0 & {\color{blue}0.00833} & 0.10833 & 0.05\\ \end{bmatrix} \)
\( 5^{th}=5^{th}-3^{rd}*A(5,3)=5^{th}-3^{rd}*0.00833 \)
\( {\bf L}= \begin{bmatrix} 0.10833 & 0 & 0 & 0 & 0 \\ 0.05 & 0.17821 & 0 & 0 & 0 \\ 0.00833 & -0.12244 & 0.27476 & 0 & 0 \\ 0 & 0.00833 & 0.19173 & 1 & 0 \\ 0 & 0 & {\color{blue}0.00833} & 0 & 1 \\ \end{bmatrix} \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 1 & 0.52617 & 0.02082 \\ 0 & 0 & 0 & 0.38901 & 0.10395 \\ 0 & 0 & 0 & 0.10833-0.52618*0.00833 & 0.05-0.02082*0.00833\\ \end{bmatrix} \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 1 & 0.52617 & 0.02082 \\ 0 & 0 & 0 & {\color{blue}0.38901} & 0.10395 \\ 0 & 0 & 0 & 0.10395 & 0.04983\\ \end{bmatrix} \)
We scale the fourth row by saving the appropriate value in the matrix \( {\bf L } \)
\( 4^{th} =4^{th}1/A(4,4) = 4^{th} / 0.38901=4^{th}*2.5706 \)
\( {\bf L}= \begin{bmatrix} 0.10833 & 0 & 0 & 0 & 0 \\ 0.05 & 0.17821 & 0 & 0 & 0 \\ 0.00833 & -0.12244 & 0.27476 & 0 & 0 \\ 0 & 0.00833 & 0.19173 & {\color{blue}0.38901} & 0 \\ 0 & 0 & 0.00833 & 0 & 1 \\ \end{bmatrix} \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 1 & 0.52617 & 0.02082 \\ 0 & 0 & 0 & 0.38901*2.5706 & 0.10395*2.5706 \\ 0 & 0 & 0 & 0.10395 & 0.04982\\ \end{bmatrix} \)
We eliminate rows by writing the appropriate values in the matrix \( {\bf L } \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 1 & 0.52617 & 0.02082 \\ 0 & 0 & 0 & 1 & 0.26721 \\ 0 & 0 & 0 & {\color{blue}0.10395} & 0.04983 \\ \end{bmatrix} \)
\( 5^{th}=5^{th}-4^{rd}*A(5,4)=5^{th}-4^{rd}*0.10395 \)
\( {\bf L}= \begin{bmatrix} 0.10833 & 0 & 0 & 0 & 0 \\ 0.05 & 0.17821 & 0 & 0 & 0 \\ 0.00833 & -0.12244 & 0.27476 & 0 & 0 \\ 0 & 0.00833 & 0.19173 & 0.38901 & 0 \\ 0 & 0 & 0.00833 & {\color{blue}0.10395} & 1 \\ \end{bmatrix} \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 1 & 0.52617 & 0.02082 \\ 0 & 0 & 0 & 1 & 0.26721 \\ 0 & 0 & 0 & 0 & 0.04983-0.26721*0.10395 \\ \end{bmatrix} \)
We scale the fifth row by saving the appropriate value in the matrix \( {\bf L } \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 1 & 0.52617 & 0.02082 \\ 0 & 0 & 0 & 1 & 0.26721 \\ 0 & 0 & 0 & 0 & {\color{blue}0.022053} \\ \end{bmatrix} \)
\( 5^{th}=5^{th}/A(5,5)=5^{th}/0.022053=5^{th}*45.351 \)
\( {\bf L}= \begin{bmatrix} 0.10833 & 0 & 0 & 0 & 0 \\ 0.05 & 0.17821 & 0 & 0 & 0 \\ 0.00833 & -0.12244 & 0.27476 & 0 & 0 \\ 0 & 0.00833 & 0.19173 & 0.38901 & 0 \\ 0 & 0 & 0.00833 & 0.10395 & {\color{blue}0.022053} \\ \end{bmatrix} \)
\( {\bf U}= \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 1 & 0.52617 & 0.02082 \\ 0 & 0 & 0 & 1 & 0.26721 \\ 0 & 0 & 0 & 0 & 1 \\ \end{bmatrix} \)
We have got the following \( {\bf LUP } \) decomposition of the matrix \( {\bf A } \)
\( {\bf LUP}= \begin{bmatrix} 0.10833 & 0 & 0 & 0 & 0 \\ 0.05 & 0.17821 & 0 & 0 & 0 \\ 0.00833 & -0.12244 & 0.27476 & 0 & 0 \\ 0 & 0.00833 & 0.19173 & 0.38901 & 0 \\ 0 & 0 & 0.00833 & 0.10395 & 0.022053 \\ \end{bmatrix} * \\ * \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 1 & 0.52617 & 0.02082 \\ 0 & 0 & 0 & 1 & 0.26721 \\ 0 & 0 & 0 & 0 & 1 \\ \end{bmatrix} * \begin{bmatrix} 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 \\ 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 1 \\ \end{bmatrix} \)
We can check its correctness \( {\bf LUP}={\bf A} \).


Ostatnio zmieniona Sobota 09 z Lipiec, 2022 07:59:37 UTC Autor: Maciej Paszynski
Zaloguj się/Zarejestruj w OPEN AGH e-podręczniki
Czy masz już hasło?

Hasło powinno mieć przynajmniej 8 znaków, litery i cyfry oraz co najmniej jeden znak specjalny.

Przypominanie hasła

Wprowadź swój adres e-mail, abyśmy mogli przesłać Ci informację o nowym haśle.
Dziękujemy za rejestrację!
Na wskazany w rejestracji adres został wysłany e-mail z linkiem aktywacyjnym.
Wprowadzone hasło/login są błędne.